<!--suppress ALL -->
<include file="./Template/header.html" />

<link rel="stylesheet" type="text/css" href="/Template/css/specialOrder.css?v=2022102603">
<script type="text/javascript" src="/Template/js/amazeui.js"></script>
<script type="text/javascript">


    $(function() {

        //初始化页面配置
        initPage("订单确认");

        var app = new Vue({
            el: '#container',
            data: {
                number: 0,
                singlePrice: $("input[name=salePrice]").val(),
                sizeList: [],
                sizeDetailList: [],
                sizeNum: [],
                num:0,
                submit:0
            },
            methods: {
                setSalePrice: function() {
                    app.singlePrice = $("input[name=salePrice]").val();
                },
                calculate: function(num) {
                    if((num+app.number)>0) {
                        app.number += num;
                    }
                },
//                calculate: function(num, index) {
//                    var sizeNum = "sizeNum_"+ index;
//                    if((num+app.sizeNum[index])>=0) {
//                        app.number += num;
//                        app.sizeNum[index] += num;
//                        document.getElementById(sizeNum).innerHTML = app.sizeNum[index];
//                    }
//                    var sizeName = "sizeName_"+ index;
//                    if(app.sizeNum[index] == 0){
//                        document.getElementById(sizeNum).style.color="black";
//                        document.getElementById(sizeName).style.color="black";
//                    }else{
//                        document.getElementById(sizeNum).style.color="red";
//                        document.getElementById(sizeName).style.color="red";
//                    }
//                },
                cancelOrder: function () {
                    window.location.href = "/wechat/specialProduct";
                },
                addCart: function() {
                    var specialProductId = "{$specialProduct.special_product_id}";
                    var salePrice = $("input[name=salePrice]").val();
                    var number = app.number;
//                    var deliveryType = $("select[name=deliveryType]").val();
//                    var receiveName = $("input[name=receiveName]").val();
//                    var receiveContact = $("input[name=receiveContact]").val();
//                    var receiveAddress = $("input[name=receiveAddress]").val();
                    var room = $("input[name=room]").val();
                    var doctorName = $("input[name=doctorName]").val();
                    var patientName = $("input[name=patientName]").val();
                    var patientId = $("input[name=patientId]").val();
                    var prosthetistId = $("select[name=prosthetistId]").val();
                    var prosthetistName = $("input[name=prosthetistName]").val();
                    var prepayment = $("input[name=prepayment]").val();
//                    var productType = $("select[name=productType]").val();
                    var note = $("input[name=note]").val();
                    var needInvoice = $("select[name=needInvoice]").val();
                    var invoiceName = $("input[name=invoiceName]").val();
                    var invoiceNumber = $("input[name=invoiceNumber]").val();
                    var invoiceDetail = $("input[name=invoiceDetail]").val();
                    var needPatient = $("input[name=needPatient]").val();
                    var agentName = $("select[name=agent]").find("option:selected").text();
                    if( isNullOrEmpty(agentName) ){
                        agentName = $("input[id=agent]").val();
                    }
                    var size = app.sizeNum[0];
                    for(var i=1;i<app.sizeList.length;i++){
                        size += "/";
                        size += app.sizeNum[i];
                    }

                    if("{$specialProduct.has_agent}" != "" && isNullOrEmpty(agentName)) {
                        alert("请选择渠道");
                        return false;
                    }

                    if(isNullOrEmpty(salePrice)) {
                        alert("请填写销售单价");
                        return false;
                    }
                    var data = {};
                    var limitPrice = parseInt("{$specialProduct.price}") * "{$specialProduct.discount}";
                    if(salePrice < limitPrice) {
                        alert("销售单价低于 " + limitPrice +" 元，无法添加购物车，请单独下单方可提交申请。");
                        return false;
                    }

                    if(number == 0) {
                        alert("请选择规格");
                        return false;
                    }



                    data.specialProductId = specialProductId;
                    data.salePrice = salePrice;
                    data.size = size;
                    data.number = number;
//                    data.deliveryType = deliveryType;
//                    data.receiveName = receiveName;
//                    data.receiveContact = receiveContact;
//                    data.receiveAddress = receiveAddress;
                    data.room = room;
                    data.doctorName = doctorName;
                    data.patientName = patientName;
                    data.patientId = patientId;
                    data.prosthetistId = prosthetistId;
                    data.prosthetistName = prosthetistName;
                    data.prepayment = prepayment;
                    data.productType = "{$class.class_name}";
                    data.note = note;
                    data.needInvoice = needInvoice;
                    data.invoiceName = invoiceName;
                    data.invoiceNumber = invoiceNumber;
                    data.invoiceDetail = invoiceDetail;
                    data.agentName = agentName;
                    localStorage.setItem("cartOrderData", JSON.stringify(data));
                    localStorage.setItem("specialOrderData", JSON.stringify(data));
                    if(confirm("请确认是否添加？")){
                        $.ajax({
                            url:"/wechat/specialProduct/addCart",
                            type:"post",
                            data:data,
                            dataType:"JSON",
                            beforeSend:function(){
                                $("#loadingToast").show();
                                $("#cartBtn").hide();
                            },
                            complete:function(){
                                $('#loadingToast').hide();
                            },
                            success:function(data){
                                if(data.code != 200) {
                                    alert(data.msg);
                                    window.location.href = "/wechat/specialProduct/orderCart";
                                }else{
                                    window.location.href = "/wechat/specialProduct/orderCart";
                                }

                            },
                            error:function(data){
                                window.location.href = "/wechat/specialProduct/orderCart";
                            }
                        })
                    }else{
                        return;
                    }


                },

                createOrder: function() {

                    var specialProductId = "{$specialProduct.special_product_id}";
                    var salePrice = $("input[name=salePrice]").val();
//                    var size = $("input[name=size]").val();
                    var number = app.number;
//                    var deliveryType = $("select[name=deliveryType]").val();
//                    var receiveName = $("input[name=receiveName]").val();
//                    var receiveContact = $("input[name=receiveContact]").val();
//                    var receiveAddress = $("input[name=receiveAddress]").val();
                    var room = $("input[name=room]").val();
                    var doctorName = $("input[name=doctorName]").val();
                    var patientName = $("input[name=patientName]").val();
                    var patientId = $("input[name=patientId]").val();
                    var prosthetistId = $("select[name=prosthetistId]").val();
                    var prosthetistName = $("input[name=prosthetistName]").val();
                    var prepayment = $("input[name=prepayment]").val();
//                    var productType = $("select[name=productType]").val();
                    var paymentType = $("select[name=paymentType]").val();
                    var note = $("input[name=note]").val();
                    var needInvoice = $("select[name=needInvoice]").val();
                    var invoiceName = $("input[name=invoiceName]").val();
                    var invoiceNumber = $("input[name=invoiceNumber]").val();
                    var invoiceDetail = $("input[name=invoiceDetail]").val();
                    var needPatient = $("input[name=needPatient]").val();
                    var needPay = $("input[name=needPay]").val();
                    var agentName = $("select[name=agent]").find("option:selected").text();
                    if( isNullOrEmpty(agentName) ){
                        agentName = $("input[id=agent]").val();
                    }
                    var size = app.sizeNum[0];
                    for(var i=1;i<app.sizeList.length;i++){
                        size += "/";
                        size += app.sizeNum[i];
                    }

                    if("{$specialProduct.has_agent}" != "" && isNullOrEmpty(agentName)) {
                        alert("请选择渠道");
                        return false;
                    }

                    if(isNullOrEmpty(salePrice)) {
                        alert("请填写销售单价");
                        return false;
                    }
                    var data = {};
                    var limitPrice = parseInt("{$specialProduct.price}") * "{$specialProduct.discount}";
                    if(salePrice < limitPrice) {
//                        alert("销售单价必须高于 " + limitPrice +" 元");
//                        return false;
                        if(confirm("销售单价 [" + salePrice + "] 元 低于 [" + limitPrice +"] 元，将提交到审核人，待其批准后方可出库，是否继续？")) {
                            data.needApproval = 1;
                        }else{
                            return false;
                        }
                    }



                    if(number == 0) {
                        alert("请选择规格");
                        return false;
                    }

//                    if(agentName == "") {
                    if(needPatient == 1) {
                        if (isNullOrEmpty(patientName)) {
                            alert("请填写患者姓名");
                            return false;
                        }
                        if (isNullOrEmpty(patientId)) {
                            alert("请填写患者ID");
                            return false;
                        }
                    }

                    if(isNullOrEmpty(room)) {
                        alert("请填写科室");
                        return false;
                    }
//
//                    if(isNullOrEmpty(doctorName)) {
//                        alert("请填写医生姓名");
//                        return false;
//                    }

                    if(isNullOrEmpty(paymentType)) {
                        alert("请选择付款方式");
                        return false;
                    }

                    if(paymentType == "预付" && isNullOrEmpty(prepayment)){
                        alert("请填写预付金额");
                        return false;
                    }
//                    if(isNullOrEmpty(receiveName)) {
//                        alert("请填写收货人姓名");
//                        return false;
//                    }

//                    if(isNullOrEmpty(deliveryType)) {
//                        alert("请选择提货方式");
//                        return false;
//                    }
//
//                    if(deliveryType != "自提"){
//                        if(isNullOrEmpty(receiveAddress)) {
//                            alert("请填写收货人地址");
//                            return false;
//                        }
//                    }
//
//                    if(isNullOrEmpty(receiveContact)) {
//                        alert("请填写收货人电话");
//                        return false;
//                    }
//
//                    if(!checkPhone(receiveContact)) {
//                        alert("手机号位数不对");
//                        return false;
//                    }

                    if(needInvoice == 1) {
                        if(isNullOrEmpty(invoiceName)) {
                            alert("请填写发票抬头");
                            return false;
                        }
                        if(isNullOrEmpty(invoiceNumber)) {
                            alert("请填写纳税人识别号");
                            return false;
                        }
                    }
//                    if(needInvoice != -1) {
//                        if(isNullOrEmpty(invoiceDetail)) {
//                            alert("请填写发票明细");
//                            return false;
//                        }
//                    }

                    data.specialProductId = specialProductId;
                    data.salePrice = salePrice;
                    data.size = size;
                    data.number = number;
//                    data.deliveryType = deliveryType;
//                    data.receiveName = receiveName;
//                    data.receiveContact = receiveContact;
//                    data.receiveAddress = receiveAddress;
                    data.room = room;
                    data.doctorName = doctorName;
                    data.patientName = patientName;
                    data.patientId = patientId;
                    data.prosthetistId = prosthetistId;
                    data.prosthetistName = prosthetistName;
                    data.prepayment = prepayment;
                    data.productType = "{$class.class_name}";
                    data.paymentType = paymentType;
                    data.needPay = needPay;
                    data.note = note;
                    data.needInvoice = needInvoice;
                    data.invoiceName = invoiceName;
                    data.invoiceNumber = invoiceNumber;
                    data.invoiceDetail = invoiceDetail;
                    data.agentName = agentName;

                    var text = "请确认是否提交订单？"
                    if(paymentType == "微信现结" && needPay == "1"){
                        text =  "请确认是否提交订单并支付 " + salePrice * number + " 元？"
                    }
                    if(confirm(text)){
                        $.ajax({
                            url:"/wechat/specialProduct/createOrder",
                            type:"post",
                            data:data,
                            dataType:"JSON",
                            beforeSend:function(){
                                $("#loadingToast").show();
                                $("#submitBtn").hide();
                            },
                            complete:function(){
                                $('#loadingToast').hide();
                            },
                            success:function(data){
                                if(data.code != 200) {
                                    alert(data.msg);
                                    app.submit = 1;
                                    window.localStorage.setItem("specialOrderData", null);
                                    window.localStorage.removeItem("specialOrderData");
                                    if(paymentType == "微信现结" && needPay == "1"){
                                        window.location.href = "/wechat/userCenter/payInfo/id/"+data.special_order_no;
                                    }else{
                                        window.location.href = "/wechat/specialProduct/orderList";
                                    }
                                }else{
                                    app.submit = 1;
                                    window.localStorage.setItem("specialOrderData", null);
                                    window.localStorage.removeItem("specialOrderData");
                                    if(paymentType == "微信现结" && needPay == "1"){
                                        window.location.href = "/wechat/userCenter/payInfo/id/"+data.special_order_no;
                                    }else{
                                        window.location.href = "/wechat/specialProduct/orderList";
                                    }
                                }

                            },
                            error:function(data){
                                app.submit = 1;
                                window.localStorage.setItem("specialOrderData", null);
                                window.localStorage.removeItem("specialOrderData");
                                if(paymentType == "微信现结" && needPay == "1"){
                                    window.location.href = "/wechat/userCenter/payInfo/id/"+data.special_order_no;
                                }else{
                                    window.location.href = "/wechat/specialProduct/orderList";
                                }
                            }
                        })
                    }else{
                        return;
                    }


                }
            }
        })

        if("{$specialProduct.has_agent}" != "1"){
//            $("input[name=salePrice]").val("{$specialProduct.price}");
            $("input[name=salePrice]").removeAttr("readonly");
        }

        var size = "{$specialProduct.size}";
        app.sizeList = size.split("/");
        var sizeDetailList = "{$specialProduct.size_detail}"
        app.sizeDetailList = sizeDetailList.split("/");
        for(var i=0;i<app.sizeDetailList.length;i++){
            if(app.sizeDetailList[i] != ""){
                app.sizeDetailList[i] = "[" + app.sizeDetailList[i] + "] -- ";
            }

        }

        for(var j=0;j<app.sizeList.length;j++){
            app.sizeNum[j] = 0;
        }

        var isPageHide = false;
        window.addEventListener('pageshow', function () {
            if (isPageHide) {
                window.location.reload();
            }
        });
        window.addEventListener('pagehide', function () {
            isPageHide = true;
            var data = {};
            var specialProductId = "{$specialProduct.special_product_id}";
            var salePrice = $("input[name=salePrice]").val();
//            var size = $("input[name=size]").val();
            var number = app.number;
//            var deliveryType = $("select[name=deliveryType]").val();
//            var receiveName = $("input[name=receiveName]").val();
//            var receiveContact = $("input[name=receiveContact]").val();
//            var receiveAddress = $("input[name=receiveAddress]").val();
            var room = $("input[name=room]").val();
            var doctorName = $("input[name=doctorName]").val();
            var patientName = $("input[name=patientName]").val();
            var patientId = $("input[name=patientId]").val();
            var prosthetistId = $("select[name=prosthetistId]").val();
            var prosthetistName = $("input[name=prosthetistName]").val();
            var prepayment = $("input[name=prepayment]").val();
//            var productType = $("select[name=productType]").val();
            var note = $("input[name=note]").val();
            var needInvoice = $("select[name=needInvoice]").val();
            var invoiceName = $("input[name=invoiceName]").val();
            var invoiceNumber = $("input[name=invoiceNumber]").val();
            var invoiceDetail = $("input[name=invoiceDetail]").val();
            var agentName = $("select[name=agent]").find("option:selected").text();
            var needPatient = $("input[name=needPatient]").val();
            var needPay = $("input[name=needPay]").val();
            if(isNullOrEmpty(agentName)){
                agentName = $("input[id=agent]").val();
            }
            var paymentType = $("select[name=paymentType]").val();
            var size = app.sizeNum[0];
            for(var i=1;i<app.sizeList.length;i++){
                size += "/";
                size += app.sizeNum[i];
            }

            data.specialProductId = specialProductId;
            data.salePrice = salePrice;
            data.size = size;
            data.number = number;
//            data.deliveryType = deliveryType;
//            data.receiveName = receiveName;
//            data.receiveContact = receiveContact;
//            data.receiveAddress = receiveAddress;
            data.room = room;
            data.doctorName = doctorName;
            data.patientName = patientName;
            data.patientId = patientId;
            data.prosthetistId = prosthetistId;
            data.prosthetistName = prosthetistName;
            data.prepayment = prepayment;
//            data.productType = productType;
            data.note = note;
            data.needInvoice = needInvoice;
            data.invoiceName = invoiceName;
            data.invoiceNumber = invoiceNumber;
            data.invoiceDetail = invoiceDetail;
            data.agentName = agentName;
            data.needPatient = needPatient;
            data.needPay = needPay;
            data.paymentType = paymentType;

            if(app.submit == 0){
                localStorage.setItem("specialOrderData", JSON.stringify(data));
            }
        });

        $(".item select").change(function() {
            var value = $(this).find("option:selected").text();
            $(this).prev().val(value);
        });

        $("input[name=salePrice]").change(function() {
            $(".size-detail").show();
            $(".size-comment").show();
        });

        $("select[name=agent]").change(function() {
            $(".size-detail").show();
            $(".size-comment").show();
            var agentArr = $("select[name=agent]").val().split(",");
            var agentPrice = agentArr[0];
            var agentName = $("select[name=agent]").find("option:selected").text();
            if(agentName == "员工下单"){
                agentPrice = "{$specialProduct.price}";
            }
            var agentContact= agentArr[1];
            var agentTel = agentArr[2];
            var agentAddress = agentArr[3];
            var agentInvoiceName = agentArr[4];
            var agentInvoiceNumber = agentArr[5];
            var needPatient = agentArr[6];
            var fixedPrice = agentArr[7];
            var deliveryType = agentArr[8];
            var paymentType = agentArr[9];
            var needInvoice = agentArr[10];
            var needPay = agentArr[11];
            var agentNote = agentArr[12];
            var agentInvoiceDetail = agentArr[13];
            if(needPatient != "1"){
                $("input[name=salePrice]").attr("readonly","readonly");
//                $(".customer-info.agent").hide();
//                $(".patient-info.agent").hide();
//                $(".doctor-info.agent").hide();
                $("input[name=patientName]").attr('placeholder','非必填');
                $("input[name=patientName]").val("");
            }else{
                $("input[name=salePrice]").removeAttr("readonly");
//                $(".customer-info.agent").show();
                $(".patient-info.agent").show();
                $("input[name=patientName]").attr('placeholder','填写患者姓名');
//                $(".doctor-info.agent").show();

            }
            if(fixedPrice != "1"){
                $("input[name=salePrice]").removeAttr("readonly");
            }else{
                $("input[name=salePrice]").attr("readonly","readonly");
            }

            document.getElementById("productPrice").innerHTML = "¥ " + agentPrice;
            $("input[name=salePrice]").val(agentPrice);
            app.singlePrice = agentPrice;
            $("input[name=needPatient]").val(needPatient);
            $("input[name=needPay]").val(needPay);
//            $("input[name=productType]").val("{$class.class_name}");
//            $("select[name=productType]").val("{$class.class_name}");
            if(agentName != "员工下单"){
//                $("input[name=receiveName]").val(agentContact);
//                $("input[name=receiveContact]").val(agentTel);
//                $("input[name=receiveAddress]").val(agentAddress);
                $("input[name=invoiceName]").val(agentInvoiceName);
                $("input[name=invoiceNumber]").val(agentInvoiceNumber);
                $("input[name=invoiceDetail]").val(agentInvoiceDetail);
                $("input[name=note]").val(agentNote);

                $("input[name=prosthetistName]").val("{$prosthetist.admin_name}");
                $("select[name=prosthetistId]").val("{$prosthetist.employee_id}");
//                $("input#transport").val(deliveryType);
                $(".item.receiveAddress").show();
                $("select[name=paymentType]").val(paymentType);
                $("input[name=paymentType]").val(paymentType);
                if(paymentType == "预付"){
                    $(".item.prepayment").show();
                }else{
                    $(".item.prepayment").hide();
                    $("input[name=prepayment]").val("");
                }

                if(needInvoice == 1){
                    $("select[name=needInvoice]").val(needInvoice);
                    $("input[name=needInvoice]").val("公司发票");
                    $(".item.invoice").show();
                    $(".item.invoiceDetail").show();
                }
            }
//            if(deliveryType == "自提") {
//                $(".item.receiveAddress").hide();
//            } else {
//                $(".item.receiveAddress").show();
//            }
        });

        $("select[name=paymentType]").change(function() {
            var agentArr = $("select[name=agent]").val().split(",");
            $("input[name=needPay]").val(agentArr[11]);

            if($("select[name=paymentType]").val() == "预付"){
                $(".item.prepayment").show();
            }else{
                $(".item.prepayment").hide();
                $("input[name=prepayment]").val("");
            }
        });


        $("select[name=needInvoice]").change(function() {
            if($(this).val() == 1) {
                $(".item.invoice").show();
                $("input[name=invoiceDetail]").val("")
            } else {
                $(".item.invoice").hide();
            }
            if($(this).val() == -1) {
                $(".item.invoiceDetail").hide();
            } else {
                $(".item.invoiceDetail").show();
            }
            if($(this).val() == 2) {
                $("input[name=invoiceDetail]").val($("input[name=patientName]").val());
            }
        });

//        $("select[name=deliveryType]").change(function() {
//            if($(this).val() == "自提") {
//                $(".item.receiveAddress").hide();
//            } else {
//                $(".item.receiveAddress").show();
//            }
//        });

        $("img.icon-up").click(function() {

            $(this).hide();
            $("img.icon-down").show();

            $(".size-detail").toggle();
            $(".size-comment").toggle();

        });

        $("img.icon-down").click(function() {

            $(this).hide();
            $("img.icon-up").show();

            $(".size-detail").toggle();
            $(".size-comment").toggle();
        });

        if(!isNullOrEmpty("{$defaultAgent.agent_name}")){
            $("select[name=agent]").find("option:contains('{$defaultAgent.agent_name}')").prop("selected", true);
            $("select[name=agent]").trigger('change');
            $("input[id=agent]").val("{$defaultAgent.agent_name}");
        }
        var leftData = window.localStorage.getItem("specialOrderData");
        var specialOrderData = JSON.parse(leftData);
        if(!isNullOrEmpty(specialOrderData) && specialOrderData.specialProductId == "{$specialProduct.special_product_id}") {
            app.number = specialOrderData.number;
//            $("select[name=deliveryType]").val(specialOrderData.deliveryType);
//            $("input[name=receiveName]").val(specialOrderData.receiveName);
//            $("input[name=receiveContact]").val(specialOrderData.receiveContact);
//            $("input[name=receiveAddress]").val(specialOrderData.receiveAddress);
            $("input[name=room]").val(specialOrderData.room);
            $("input[name=doctorName]").val(specialOrderData.doctorName);
            $("input[name=patientName]").val(specialOrderData.patientName);
            $("input[name=patientId]").val(specialOrderData.patientId);
            $("input[name=prosthetistName]").val(specialOrderData.prosthetistName);
            $("input[name=prepayment]").val(specialOrderData.prepayment);
//            $("select[name=productType]").val(specialOrderData.productType);
            $("input[name=note]").val(specialOrderData.note);
            $("select[name=needInvoice]").val(specialOrderData.needInvoice);
            $("input[name=invoiceName]").val(specialOrderData.invoiceName);
            $("input[name=invoiceNumber]").val(specialOrderData.invoiceNumber);
            $("input[name=invoiceDetail]").val(specialOrderData.invoiceDetail);
//            $("input#transport").val(specialOrderData.deliveryType);
            $("input[name=paymentType]").val(specialOrderData.paymentType);
            $("select[name=paymentType]").val(specialOrderData.paymentType);
            if(specialOrderData.paymentType == "预付"){
                $(".item.prepayment").show();
            }else{
                $(".item.prepayment").hide();
                $("input[name=prepayment]").val("");
            }
            var value = $("select[name=needInvoice]").find("option:selected").text();
            $("select[name=needInvoice]").prev().val(value);

            if($("select[name=needInvoice]").val() == 1) {
                $(".item.invoice").show();
            } else {
                $(".item.invoice").hide();
            }
            if($("select[name=needInvoice]").val() == -1) {
                $(".item.invoiceDetail").hide();
            } else {
                $(".item.invoiceDetail").show();
            }

//            if($("select[name=deliveryType]").val() == "自提") {
//                $(".receiveAddress").hide();
//            } else {
//                $(".receiveAddress").show();
//            }
            if(isNullOrEmpty(specialOrderData.agentName) && ("{$specialProduct.has_agent}" == "1")){
                return;
            }
            if(!isNullOrEmpty(specialOrderData)) {
                if(specialOrderData.specialProductId == "{$specialProduct.special_product_id}") {
                    if(!isNullOrEmpty(specialOrderData.agentName)){
                        $("input[id=agent]").val(specialOrderData.agentName);
                        $("select[name=agent]").find("option:contains('{specialOrderData.agentName}')").prop("selected", true);
                    }
//                    app.number = specialOrderData.number;
                    if(!isNullOrEmpty(specialOrderData.salePrice)){
                        document.getElementById("productPrice").innerHTML = "¥ " + specialOrderData.salePrice;
                        app.singlePrice = specialOrderData.salePrice;
                        $("input[name=salePrice]").val(specialOrderData.salePrice);
                    }

//                    $("input[name=size]").val(specialOrderData.size);
//                    app.sizeNum = specialOrderData.size.split("/");
//                    app.sizeNum=app.sizeNum.map(function(data){
//                        return +data;
//                    });
                    if(!isNullOrEmpty(specialOrderData.needPatient)) {
                        $("input[name=needPatient]").val(specialOrderData.needPatient);
                    }
                    if(!isNullOrEmpty(specialOrderData.needPay)) {
                        $("input[name=needPay]").val(specialOrderData.needPay);
                    }
                    if(specialOrderData.agentName == "员工下单"){
                        $("input[name=salePrice]").removeAttr("readonly");
                    }else{
                        $("input[name=salePrice]").attr("readonly","readonly");
                    }
                    if(("{$specialProduct.has_agent}" == "1") && (specialOrderData.needPatient != "1")) {
                        $("input[name=salePrice]").attr("readonly","readonly");
//                        $(".customer-info.agent").hide();
//                        $(".patient-info.agent").hide();
//                        $(".doctor-info.agent").hide();
                        $("input[name=patientName]").attr('placeholder','非必填');
                        document.getElementById("productPrice").innerHTML = "¥ " + specialOrderData.salePrice;
                    }
                } else {

                }

            }

        }else{
            app.number = 1;
            $("input[id=agent]").val("");
            $("input[name=salePrice]").val("");
//            $("select[name=deliveryType]").val("");
//            $("input[name=receiveName]").val("");
//            $("input[name=receiveContact]").val("");
//            $("input[name=receiveAddress]").val("");
            $("input[name=room]").val("");
            $("input[name=doctorName]").val("");
            $("input[name=patientName]").val("");
            $("input[name=patientId]").val("");
//            $("input[name=prosthetistName]").val();
            $("input[name=prepayment]").val("");
//            $("input[name=productType]").val("{$class.class_name}");
            $("input[name=note]").val("");
            $("select[name=needInvoice]").val("");
            $("input[name=invoiceName]").val("");
            $("input[name=invoiceNumber]").val("");
            $("input[name=invoiceDetail]").val("");
            $("input#transport").val("");
            $("select[name=needInvoice]").val(-1);
            $("input[name=needPatient]").val("");
            $("input[name=needPay]").val("");
            if(!isNullOrEmpty("{$defaultAgent.agent_name}")){
                $("select[name=agent]").find("option:contains('{$defaultAgent.agent_name}')").prop("selected", true);
                $("select[name=agent]").trigger('change');
                $("input[id=agent]").val("{$defaultAgent.agent_name}");
            }
        }
    })
    window.onload = function () {
        if($("input[id=agent]").val() != ""){
            $(".size-detail").show();
            $(".size-comment").show();
            $("#cartBtn").hide();
        }
    }
</script>

<div class="container" id="container">
    <div class="product-detail">
        <img class="product-img" src="{$specialProduct.image_url}" alt="product">
        <div class="detail-info">
            <p class="product-price" id="productPrice">￥{$specialProduct.price}</p>
            <p class="product-name">{$specialProduct.name}</p>
            <p class="number">×{{number}}</p>
            <p class="buy-time">订购日期：{:date("Y-m-d")}</p>
        </div>
    </div>
    <div class="number-and-transport">
        <if condition="$specialProduct['has_agent'] eq '1'">
            <!--div class="item">
                <span>渠道</span>
                <input id="agent" value="" type="text" readonly placeholder="请选择渠道">
                <select name="agent">
                    {:getAgentSelectOptionHtml($specialProduct['special_product_id'], $agentId)}
                </select>
                <img class="icon-right gender" src="/Template/images/icon-right.png" alt="">
            </div-->
            <div class="item">
                <span>渠道</span>
                <input id="agent" value="" type="text" readonly placeholder="请选择渠道">
                <select name="agent">
                    {:getSpecialAgentSelectOption($specialProduct['special_product_id'], $user['agent_id'], $user['enterprise_code'])}
                </select>
                <img class="icon-right gender" src="/Template/images/icon-right.png" alt="">
            </div>
        </if>

        <div class="item salePrice">
            <span>销售单价</span>
            <input type="text" name="salePrice" readonly value="{$specialProduct.price}" placeholder="请填写销售单价" v-on:blur="setSalePrice()">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item">
            <span>数量</span>
            <span class="number-change" style="margin-right: 0rem">
                <img class="icon-minus" v-on:click="calculate(-1)" src="/Template/images/minus.png" alt="">
                <span class="sum-number">{{number}}</span>
                <img class="icon-plus" v-on:click="calculate(1)" src="/Template/images/plus.png" alt="">
            </span>
        </div>
        <!--div class="size">
            <div class="item" style="height:3rem;border-bottom:0px">
                <span>规格型号{$specialProduct.size_comment}</span>
                <img class="icon-up" src="/Template/images/icon-up.png" alt="">
                <img class="icon-down" src="/Template/images/icon-down.png" alt="">
            </div>
            <span class="size-comment" style="display: none">{$specialProduct.size_comment}</span>
            <br/>
            <div v-for="size in sizeList" class="size-detail" style="display: none">
                <div class="item-small">
                    <span class="sum-number" id="sizeName_{{ $index }}">{{sizeDetailList[$index]}}{{size}}</span>
                    <span class="number-change">
                            <img class="icon-plus" v-on:click="calculate(-1, $index)" src="/Template/images/minus.png" alt="">
                            <span class="sum-number" id="sizeNum_{{ $index }}">{{sizeNum[$index]}}</span>
                            <img class="icon-plus" v-on:click="calculate(1, $index)" src="/Template/images/plus.png" alt="">
                    </span>
                </div>
            </div>
        </div-->
    </div>

    <div class="patient-info agent">
        <div class="item">
            <span>科室</span>
            <input type="text" name="room" placeholder="填写科室">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item">
            <span>医生姓名</span>
            <input type="text" name="doctorName" placeholder="填写医生">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item">
            <span>患者姓名</span>
            <input type="text" name="patientName" placeholder="填写患者姓名">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item">
            <span>患者ID</span>
            <input type="text" name="patientId" placeholder="填写患者ID">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item">
            <span>支具师</span>
            <input name="prosthetistName" type="text" value="{$prosthetist.admin_name}" readonly placeholder="选择支具师">
            <select name="prosthetistId">
                <option value="{$prosthetist.employee_id}">请选择</option>
                {:getEmployeeSelectOptionHtml($user['enterprise_code'],"12",null)}
            </select>
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <!--div class="item">
            <span>支具类型</span>
            <input name="productType" type="text" readonly placeholder="选择支具类型">
            <select name="productType">
                <option value="">请选择</option>
                <option value="高温板">高温板</option>
                <option value="低温板">低温板</option>
            </select>
            <img class="icon-right gender" src="/Template/images/icon-right.png" alt="">
        </div-->
        <input type="text" style="display: none;" name="needPatient">
        <!--<input type="text" style="display: none;" name="needPay">-->
    </div>
    <!--div class="doctor-info agent">
        <div class="item">
            <span>医生</span>
            <input type="text" name="doctorName" placeholder="多个患者可不填">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item">
            <span>医院</span>
            <input type="text" name="hospitalName" placeholder="多个患者可不填">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
    </div-->
    <!--div class="address-info">
        <div class="item">
            <span>提货方式</span>
            <input id="transport" value="快递包邮" type="text" readonly placeholder="请选择提货方式">
            <select name="deliveryType">
                <option value="快递包邮">快递包邮</option>
                <option value="快递到付">快递到付</option>
                <option value="自提">自提</option>
            </select>
            <img class="icon-right gender" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item">
            <span>收货人姓名</span>
            <input type="text" name="receiveName" placeholder="请填写收货人姓名">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item">
            <span>收货人电话</span>
            <input type="text" name="receiveContact" placeholder="请填写收货人电话">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item receiveAddress">
            <span>收货地址</span>
            <input type="text" name="receiveAddress" placeholder="请填写收货地址">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
    </div-->

    <div class="address-info">
        <div class="item" style="border-bottom:0px">
            <span>付款情况</span>
            <input name="paymentType" value="" type="text" readonly placeholder="请选择款方式">
            <select name="paymentType">
                <option value=""></option>
                <option value="全款">全款</option>
                <option value="预付">预付</option>
                <option value="赠送">赠送</option>
            </select>
            <img class="icon-right gender" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item prepayment" style="display: none;">
            <span>预付金额</span>
            <input name="prepayment" type="text" placeholder="请填写预付金额">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
    </div>
    <div class="product-need">
        <div class="item">
            <span>留言备注</span>
            <input type="text" name="note" placeholder="请编辑备注信息">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <!--div class="item">
            <span>是否开发票</span>
            <input type="text" value="不开发票" name="needInvoice" readonly placeholder="">
            <select name="needInvoice" class="invoice-choose">
                <option value="-1">不开发票</option>
                <option value="1">公司发票</option>
                <option value="2">个人发票</option>
            </select>
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item invoice" style="display: none;">
            <span>发票抬头</span>
            <input name="invoiceName" type="text" placeholder="请填写发票抬头">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item invoice" style="display: none;">
            <span>纳税人识别号</span>
            <input name="invoiceNumber" type="text" placeholder="请填纳税人识别号">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div>
        <div class="item invoiceDetail" style="display: none;">
            <span>发票明细</span>
            <input name="invoiceDetail" type="text" placeholder="请填写发票明细" value="{$specialProduct.invoice_detail}">
            <img class="icon-right" src="/Template/images/icon-right.png" alt="">
        </div-->
    </div>
    <div class="order-operation">
        <p style="margin-left: 20%;width: 40%">共<a style="color: #e97a15">{{number}}</a>件,合计：<span>￥{{number*singlePrice}}</span> </p>
        <button class="cancel-order" v-on:click="cancelOrder">返回</button>
        <button id="submitBtn" class="submit-order" v-on:click="createOrder">提交订单</button>
        <button id="cartBtn" class="submit-cart" v-on:click="addCart">加购物车</button>

    </div>
</div>
<include file="./Template/footer.html" />